<!DOCTYPE html PUBLIC "-//W3C//Dtd XHTML 1.0 Transitional//EN" "http://www.w3.org/tr/xhtml1/Dtd/xhtml1-transitional.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ page import="com.infodms.dms.common.Constant" %>
<%@taglib uri="/jstl/cout" prefix="c" %>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<jsp:include page="${contextPath}/common/jsp_head_new.jsp" />
<title>订单提报</title>
</head>
<body>
<div class="navigation"><img src="<%=request.getContextPath()%>/img/nav.gif" />&nbsp;当前位置：整车销售 > 销售订单管理 > 订做车需求确认 > 订做车订单提报</div>
<form method="POST" name="fm" id="fm">
	<table class=table_query>
		<tr class=cssTable>
			<td align="right">业务范围：</td>
			<td align="left">
				<select name="areaId" id="areaId" class="short_sel" disabled="disabled">
					<c:forEach items="${areaList}" var="po">
						<option <c:if test="${po.AREA_ID==reqPo.areaId}">selected</c:if> value="${po.AREA_ID}|${po.DEALER_ID}">${po.AREA_NAME}</option>
					</c:forEach>
				</select>
			</td>
			<td align="right">选择资金类型：</td>
			<td align="left">
				<select name="fundType" onchange="getAvailableAmount(this.options[this.options.selectedIndex].value);">
	      		</select>
			</td>
			<td align="right">可用余额：
				<span id="show1"></span><input type="hidden" name="availableAmount" value="0">
			</td>
			<td align="left" id="accountAmount"></td>
			<td align="right">订单总价：</td>
			<td align="left"><span id="show2"></span></td>
		</tr>
		<tr id="priceTr" class = "tabletitle">
	      <td align = "right" >价格类型：</td>
	      <td align = "left" colspan="3">
	      	<select name="priceId" onchange="priceTypeChange();" disabled="disabled">
	        </select>
	      </td>
	      <td align = "right"><span id="span7">使用其他价格原因：</span></td>
	      <td align = "left" colspan="3">
	      	<span id="span8"><input name="otherPriceReason" type="text" class="long_txt"/></span>
	      </td>
	    </tr>
	</table>
	<br>
	<table class=table_list style="border-bottom:1px solid #DAE0EE" >  
		<tr class=cssTable >
			<th nowrap="nowrap">车系</th>
			<th nowrap="nowrap">物料编号</th>
			<th nowrap="nowrap">物料名称</th>
			<th nowrap="nowrap">订做批次号</th>
			<th nowrap="nowrap">资源情况</th>
			<th nowrap="nowrap">已提报数量</th>
			<th nowrap="nowrap">数量</th>
			<th nowrap="nowrap">单价</th>
			<th nowrap="nowrap">金额</th>
			<th nowrap="nowrap">折扣率 %</th>
			<th nowrap="nowrap">折扣后单价</th>
			<th nowrap="nowrap">折扣额</th>
		</tr>
    	<c:forEach items="${list}" var="po">
    		<tr class="table_list_row2">
		      <td align="center">
		      	${po.SERIES_NAME}
		      	<input type="hidden" name="materialId" value="${po.MATERIAL_ID}"/>
		      	<input type="hidden" name="specialBatchNo" value="${po.SPECIAL_BATCH_NO}"/>
		      	<input type="hidden" id="singlePrice${po.MATERIAL_ID}" name="singlePrice" value="${po.SALES_PRICE}"/>
				<input type="hidden" id="totalPrice${po.MATERIAL_ID}" name="totalPrice" value="0"/>
				<input type="hidden" id="discountSPrice${po.MATERIAL_ID}" name="discountSPrice" value="0"/>
				<input type="hidden" id="discountPrice${po.MATERIAL_ID}" name="discountPrice" value="0"/>
				<input type="hidden" name="dtlId" value="${po.DTL_ID}"/>
				<input type="hidden" name="applyAmount" value="${po.APPLY_AMOUNT}"/>
				<input type="hidden" id="orderAmount${po.MATERIAL_ID}" name="orderAmount" value="${po.ORDER_AMOUNT}"/>
		      </td>
		      <td align="center">${po.MATERIAL_CODE}</td>
		      <td align="center">${po.MATERIAL_NAME}</td>
		      <td align="center">${po.SPECIAL_BATCH_NO}</td>
		      <td align="center">${po.RESOURCE_AMOUNT}</td>
		      <td align="center">${po.ORDER_AMOUNT}</td>
		      <td align="center"><input type="text" class="mini_txt" id="amount${po.MATERIAL_ID}" name="amount" value="${po.AMOUNT}" datatype='0,is_digit,6' onchange="priceTotal();"/></td>
		      <td align="center">
			      <span id='price1${po.MATERIAL_ID}'>
			      	<script type="text/javascript">
			      		document.write(amountFormat(${po.SALES_PRICE}));
			      	</script>
			      </span>
		      </td>
		      <td align="center"><span id='price2${po.MATERIAL_ID}'></span></td>
		      <td align="center"><input type="text" class="mini_txt" id="discountRate${po.MATERIAL_ID}" name="discountRate" value="0" onchange="priceOnBlue(this);priceTotal();" datatype="0,is_double,6" decimal="2"></td>
		      <td align="center"><span id='price3${po.MATERIAL_ID}'></span></td>
		      <td align="center"><span id='price4${po.MATERIAL_ID}'></span></td>
		    </tr>
    	</c:forEach>
    	<tr class="table_list_row1" >
			<td nowrap="nowrap"></td>
			<td nowrap="nowrap"></td>
			<td nowrap="nowrap"></td>
			<td nowrap="nowrap"></td>
			<td nowrap="nowrap" align="right"><strong>总计：</strong></td>
			<td nowrap="nowrap" align="center" id="orderTotal"></td>
			<td nowrap="nowrap" align="center" id="amountTotal"></td>
			<td nowrap="nowrap"></td>
			<td nowrap="nowrap" align="center" id="priceTotal"></td>
			<td nowrap="nowrap"></td>
			<td nowrap="nowrap"></td>
			<td nowrap="nowrap" align="center" id="discountTotal"></td>
		</tr>
	</table>	
	<br>
	<table class=table_query>
		<tr>
	      <th colspan="2" align="left"  nowrap="nowrap"><img class="nav" src="<%=request.getContextPath()%>/img/subNav.gif" /> 订单说明
	      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
	      <th align="right" nowrap="nowrap">&nbsp;</th>
	      <th align="right" nowrap="nowrap">&nbsp;</th>
	    </tr>
	    <tr class="cssTable" id="discountTr">
	      <td width="12%" align="right" valign="top" nowrap="nowrap">可用折让：</td>
	      <td colspan="3" align="left" valign="top" nowrap="nowrap">
	      	<input id="discount" name="discount" type="text" class="middle_txt" size="30" maxlength="30" value="0.00" datatype="1,is_double,20" decimal="2"/>
	      </td>
	    </tr>
	    <tr class="cssTable">
	      <td width="12%" align="right" valign="top" nowrap="nowrap">是否代交车：</td>
	      <td colspan="3" align="left" valign="top" nowrap="nowrap">
	      	<input type="checkbox" name="isCover" id="isCover" onclick="showFleetInfo();" value="" />
	      </td>
	    </tr>
	    <tr class="cssTable" id="cusTr" style="display:none">
	      <td align="right" nowrap="nowrap">选择集团客户：</td>
	      <td align="left" nowrap="nowrap">
		      <input id="fleetName" name="fleetName" type="text" datatype="0,is_noquotation,30"/>
			  <input id="fleetId" name="fleetId" type="hidden"/>				
			  <input class="mini_btn" type="button" value="..." onclick="showFleet();"/>
			  <input class="cssbutton" type="button" value="清除" onclick="toClear();"/>
		  </td>
	      <td align="right" nowrap="nowrap">集团客户运送地址：</td>
	      <td align="left" nowrap="nowrap">
		      <input type="text" id="fleetAddress" name="fleetAddress" size="50" datatype="0,is_noquotation,50"/>
		  </td>
	    </tr>
		<tr class="cssTable" id="tranTr">
	      <td align="right"   nowrap="nowrap">运输方式： </td>
	      <td colspan="3" align="left" nowrap="nowrap">
		      <script type="text/javascript">
		      	genSelBoxExp("deliveryType",<%=Constant.TRANSPORT_TYPE%>,"<%=Constant.TRANSPORT_TYPE_02%>",false,"short_sel","onchange='addressHide(this.options[this.options.selectedIndex].value);'","false",'');
		      </script>
	      </td>
	    </tr>
		<tbody id="addTr">
		    <tr class="cssTable">
		      <td align="right" nowrap="nowrap">收货方：</td>
		      <td align="left" nowrap="nowrap">
			      <select name="receiver" onchange="getAddressList();">
			      </select>
			  </td>
		      <td colspan="2" align="left" nowrap="nowrap">&nbsp;</td>
		    </tr>
		    <tr class="cssTable" style="display:inline">
		      <td align="right" nowrap="nowrap">运送地址：</td>
		      <td align="left" nowrap="nowrap">
			      <select name="deliveryAddress" onchange="getAddressInfo(this.options[this.options.selectedIndex].value);">
			      </select>
			  </td>
		      <td align="right" valign="top" nowrap="nowrap">收车单位：</td>
		      <td align="left" valign="top" nowrap="nowrap" id="receiveOrg"></td>
		    </tr>
		    <tr class="cssTable" >
		      <td align="right" valign="top" nowrap="nowrap">联系人：</td>
		      <td align="left" valign="top" nowrap="nowrap"><input name="linkMan" type="text" class="middle_txt" size="30" maxlength="30" /></td>
		      <td align="right" valign="top" nowrap="nowrap">联系电话：</td>
		      <td align="left" valign="top" nowrap="nowrap"><input name="tel" type="text" class="middle_txt" size="30" maxlength="30" /></td>
		    </tr>
	    </tbody>
	    <tr class=cssTable >
	      <TD height="66" align="right" nowrap>备注说明：</TD>
		  <TD colspan="3" align="left" nowrap><textarea name="orderRemark" rows="3" cols="80"></textarea></TD>
   		</tr>
		<tr class=cssTable>
			<td align="right">改装说明：</td>
			<td colspan="3" align="left"  nowrap><textarea name="refitRemark" id="refitRemark" rows="3" cols="80" readonly="readonly"><c:out value="${reqPo.refitDesc}"/></textarea></td>
		</tr>
		<tr class=cssTable >
			<td>&nbsp;</td>
			<td colspan="3" align="left">
				<input type="hidden" name="reqId" value="${reqPo.reqId}"/>
				<input type="hidden" name="area" value="${reqPo.areaId}"/>
				<input type="hidden" name="dealerId" value="${reqPo.dealerId}"/>
				<input type="hidden" name="isCheck" id="isCheck" value="${isCheck}"/>
				<input type="hidden" name="orderTotalPrice" value="0">
				<input type="hidden" name="discountTotalPrice" value="0">
				<input type="hidden" name="reqTotalAmount" value="0">
				<input type="hidden" name="ratePara" value="${ratePara}" />
				<input type="hidden" name="priceTypeId" value="" />
				<input type="button" name="button1" class="cssbutton" onclick="toConfirm();" value="提报" id="queryBtn1" /> 
				<input type="button" name="button2" class="cssbutton" onclick="history.back();" value="返回" id="queryBtn2" /> 
			</td>
		</tr>
	</table>
</form>
<script type="text/javascript">
function priceOnBlue(thisRate){
	var discountRate = thisRate.value;
	if(${returnValue==1}){
		if(discountRate!=0 && discountRate!=15){
			thisRate.value=0;
			MyAlert("微车的折扣率只能是0和15");
		}
	}
	if(${returnValue==2}){
	if(discountRate!=0 && discountRate!=10){
		thisRate.value=0;
		MyAlert("轿车的折扣率只能是0和10");
	    }
    }
}

	//初始化
	function doInit(){
		getFund();
		priceTotal();
		getPriceList();
		getReceiverList();
	}
	
	function getFund(){
		var dealerId = document.getElementById("dealerId").value;
		var url = "<%=request.getContextPath()%>/sales/ordermanage/orderreport/UrgentOrderReport/showFund.json";
		makeCall(url,showFund,{dealerId:dealerId});
	}
	
	function showFund(json){
		showFundTypeList(json);
		showDiscountInfo(json);
	}
	
	//资金类型列表显示
	function showFundTypeList(json){
		var obj = document.getElementById("fundType");
		obj.options.length = 0;
		for(var i=0;i<json.fundTypeList.length;i++){
			obj.options[i]=new Option(json.fundTypeList[i].TYPE_NAME, json.fundTypeList[i].TYPE_ID + "");
			if(json.fundTypeList[i].TYPE_ID + "" == '${reqPo.accountTypeId}'){
				obj.options[i].selected = true;
			}
		}
		
		getAvailableAmount(document.getElementById("fundType").value);
	}
	
	function getAvailableAmount(arg){
		var dealerId = document.getElementById("dealerId").value;
		var fundTypeId = arg;
		
		var url = "<%=request.getContextPath()%>/sales/ordermanage/orderreport/UrgentOrderReport/getAvailableAmount.json";
		makeCall(url,showAvailableAmount,{fundTypeId:fundTypeId,dealerId:dealerId});
	}
	
	function showAvailableAmount(json){
		var obj1 = document.getElementById("show1");
		var obj2 = document.getElementById("availableAmount");
		obj1.innerHTML = amountFormat(parseFloat(json.returnValue, 10));
		obj2.value = parseFloat(json.returnValue, 10);
		document.getElementById("accountId").value = json.accountId;
	}
	
	//可用折让显示
	function showDiscountInfo(json){
		var discount = 0;
		var discountAccountId = "";
		for(var i=0;i<json.discountList.length;i++){
			discount = json.discountList[i].AVAILABLE_AMOUNT;
			discountAccountId = json.discountList[i].ACCOUNT_ID;
		}
		
		document.getElementById("discount").value = discount;
		document.getElementById("discountAccountId").value = discountAccountId;
	}
	
	//提交校验
	function toConfirm(){
		if(submitForm('fm')){
			var flag = document.getElementById("isCheck").value;
			var total = document.getElementById("orderTotalPrice").value;
			var ava = document.getElementById("availableAmount").value;
			var discountValue = document.getElementById("discount").value;
			var discountTotal = document.getElementById("discountTotalPrice").value;
			var materialId = document.getElementsByName("materialId");
			var discountRate = document.getElementsByName("discountRate");
			var amount = document.getElementsByName("amount");
			var reqTotalAmount = document.getElementById("reqTotalAmount").value;
			var ratePara = parseInt(document.getElementById("ratePara").value, 10);
			
			var priceId = document.getElementById("priceId").value;
			document.getElementById("priceTypeId").value = priceId;
			
			for(var i=0 ;i< materialId.length; i++){
				var materialValue = materialId[i].value;
				var discountRateValue = discountRate[i].value;
				var amountValue = amount[i].value;
				var priceValue = document.getElementById("price1"+materialValue).innerHTML;
				
				if(parseFloat(discountRateValue, 10) > ratePara) {
					MyAlert("折扣率不能大于"+ratePara+"%！");
					return;
				}
				if(priceValue == "价格未维护" && parseInt(amountValue, 10) > 0){
					MyAlert("价格未维护物料提报数量不能大于0！");
					return;
				}
			}
			if(parseFloat(discountValue, 10) < parseFloat(discountTotal, 10)) {
				MyAlert("折扣额合计不能大于可用折让！");
				return;
			}
			if(flag==0 && parseFloat(total, 10)>parseFloat(ava, 10)){
				MyAlert("订单总价大于可用余额，不能提报！");
				return false;
			}
			if(parseInt(reqTotalAmount, 10) < 1) {
				MyAlert("提报数量合计不能小于1！");
				return;
			}
			MyConfirm("确认提报？",toSubmit);
		}
	}
	//提交
	function toSubmit(){
		//document.getElementById("remark").disabled=false;
		makeNomalFormCall('<%=request.getContextPath()%>/sales/ordermanage/orderreport/SpecialNeedConfirm/specialNeedToReport.json',showResult,'fm');
	}
	//回调方法
	function showResult(json){
		if(json.returnValue == '1'){
			window.parent.MyAlert("提交成功！");
			fm.action='<%=request.getContextPath()%>/sales/ordermanage/orderreport/SpecialNeedOrderReoprt/specialNeedOrderReoprtInit.do';
			fm.submit();
		}else{
			MyAlert("新增失败！请联系系统管理员！");
		}
	}
	//清除按钮
  	function toClear(){
		document.getElementById("fleetName").value="";
		document.getElementById("fleetId").value="";
  	}
    //大用户弹出
  	function showFleet(){
  		OpenHtmlWindow('<%=request.getContextPath()%>/sales/ordermanage/orderreport/SpecialNeedConfirm/queryFleetInit.do',700,500);
  	}
  	//获得价格类型列表
	function getPriceList(){	
		var dealerId = document.getElementById("dealerId").value;
		var url = "<%=request.getContextPath()%>/sales/ordermanage/orderreport/UrgentOrderReport/getPriceList.json";
		makeCall(url,showPriceList,{dealerId:dealerId});
	}	
	//显示价格类型列表
	function showPriceList(json){
		var obj = document.getElementById("priceId");
		obj.options.length = 0;
		for(var i=0;i<json.priceList.length;i++){
			if(json.priceList[i].IS_DEFAULT == '<%=Constant.IF_TYPE_YES%>'){
				obj.options[i] = new Option(json.priceList[i].PRICE_DESC + "*", json.priceList[i].PRICE_ID + "");
				if('${reqPo.priceId}' == '' || '${reqPo.priceId}' == '0'){
					obj.options[i].selected = "selected";
				}
			}
			else{
				obj.options[i] = new Option(json.priceList[i].PRICE_DESC, json.priceList[i].PRICE_ID + "");
			}
			if(json.priceList[i].PRICE_ID + "" == '${reqPo.priceId}'){
				obj.options[i].selected = "selected";
			}
		}
		isShowOtherPriceReason();
	}
	//获得收货方列表
	function getReceiverList(){	
		var dealerId = document.getElementById("dealerId").value;
		var areaId = document.getElementById("area").value;
		var url = "<%=request.getContextPath()%>/sales/ordermanage/orderreport/UrgentOrderReport/getReceiverList.json";
		makeCall(url,showReceiverList,{dealerId:dealerId, areaId:areaId});
	}	
	
	//显示收货方列表
	function showReceiverList(json){
		var obj = document.getElementById("receiver");
		obj.options.length = 0;
		for(var i=0;i<json.receiverList.length;i++){
			obj.options[i] = new Option(json.receiverList[i].DEALER_NAME, json.receiverList[i].DEALER_ID + "");
		}
		getAddressList();//获得发运地址列表
	}
	
	// 判断是否显示使用其他价格原因
	function isShowOtherPriceReason(){	
		var dealerId = document.getElementById("dealerId").value;
		var priceId = document.getElementById("priceId").value;
		var url = "<%=request.getContextPath()%>/sales/ordermanage/orderreport/UrgentOrderReport/isShowOtherPriceReason.json";
		makeCall(url,showOtherPriceReason,{dealerId:dealerId,priceId:priceId});
	}	
	
	//使用其他价格原因
	function showOtherPriceReason(json){
		if(json.returnValue == "1"){
			document.getElementById("span7").style.display = "inline";
			document.getElementById("span8").style.display = "inline";
		}
		else{
			document.getElementById("span7").style.display = "none";
			document.getElementById("span8").style.display = "none";
		}
	}
  	//价格类型改变
	function priceTypeChange(){	
		var priceId = document.getElementById("priceId").value;
		var ids = "";//已选中的物料id
		var materialId = document.getElementsByName("materialId");
		for(var i=0; i<materialId.length; i++){
			ids += materialId[i].value + ",";
		}	
		ids = (ids == "" ? ids : ids.substring(0,ids.length-1));
		var url = "<%=request.getContextPath()%>/sales/ordermanage/orderreport/UrgentOrderReport/getSinglePriceList.json";
		makeCall(url,priceChange,{priceId:priceId, ids:ids});
	}	
	
	//价格类型改变处理
	function priceChange(json){
		for(var i=0;i<json.priceList.length;i++){
			var id = json.priceList[i].MATERIAL_ID;
			var price = json.priceList[i].PRICE;
			
			var obj1 = document.getElementById("price1" + id);
			var obj2 = document.getElementById("singlePrice" + id);
			if(price > <%=Constant.MATERIAL_PRICE_MAX%>){
				obj1.innerHTML = "价格未维护";
				price = 0;
			}
			else{
				obj1.innerHTML = amountFormat(price);
			}
			obj2.value = price;
		}
		isShowOtherPriceReason();
		priceTotal();
	}
	
	//根据运输方式隐藏地址列表
	function addressHide(arg){
		var obj1 = document.getElementById("addTr");
		//自提 addTr
		if(arg == '<%=Constant.TRANSPORT_TYPE_01%>') {
			obj1.style.display = "none";
		}
		else if(arg == '<%=Constant.TRANSPORT_TYPE_02%>'){
			obj1.style.display = "inline";
		}
	}
	
	//获得地址列表
	function getAddressList(){	
		var dealerId = document.getElementById("receiver").value;
		var url = "<%=request.getContextPath()%>/sales/ordermanage/orderreport/UrgentOrderReport/getAddressList.json";
		makeCall(url,showAddressList,{dealerId:dealerId});
	}	
	
	function showAddressList(json){
		var obj = document.getElementById("deliveryAddress");
		obj.options.length = 0;
		for(var i=0;i<json.addressList.length;i++){
			obj.options[i]=new Option(json.addressList[i].ADDRESS, json.addressList[i].ID + "");
		}
		
		getAddressInfo(document.getElementById("deliveryAddress").value);
	}
	
	//获得联系人信息
	function getAddressInfo(arg){
		var addressId = arg;
		var url = "<%=request.getContextPath()%>/sales/ordermanage/orderreport/UrgentOrderReport/getAddressInfo.json";
		makeCall(url,showAddressInfo,{addressId:addressId});
	}	
	
	function showAddressInfo(json){
		var obj1 = document.getElementById("linkMan");
		var obj2 = document.getElementById("tel");
		var obj3 = document.getElementById("receiveOrg");
		if (!json.info.LINK_MAN) {
			obj1.value = '' ;
		}
		if(json.info.LINK_MAN != null && json.info.LINK_MAN != "null"){
			obj1.value = json.info.LINK_MAN;
		}
		if (!json.info.TEL) {
			obj2.value = '' ;
		}
		if(json.info.TEL != null && json.info.TEL != "null"){
			obj2.value = json.info.TEL;
		}
		if(!json.info.RECEIVE_ORG) {
			obj3.innerHTML = '' ;
		}
		if(json.info.RECEIVE_ORG != null && json.info.RECEIVE_ORG != "null"){
			obj3.innerHTML = json.info.RECEIVE_ORG;
		}
	}
	
	//是否代交车
	function showFleetInfo(){
		if(document.getElementById("isCover").checked){
			document.getElementById("cusTr").style.display = "inline";
			document.getElementById("addTr").style.display = "none";
			document.getElementById("tranTr").style.display = "none";
			document.getElementById("isCover").value = 1;
		}else{
			document.getElementById("cusTr").style.display = "none";
			document.getElementById("addTr").style.display = "inline";
			document.getElementById("tranTr").style.display = "inline";
			addressHide(document.getElementById("deliveryType").value);
			document.getElementById("isCover").value = 0;
		}
	}
	
	// 合计价格
	function priceTotal(){
		var orderTotal = 0;
		var amountTotal = 0;
		var priceTotal = 0;
		var discountTotal = 0;
		
		var materialId = document.getElementsByName("materialId");
		for(var i=0; i<materialId.length; i++){
			var subStr = materialId[i].value;
			var orderAmount = parseInt(document.getElementById("orderAmount"+subStr).value, 10);//已提报数量
			var amount = parseInt(document.getElementById("amount"+subStr).value, 10);//数量
			var singlePrice = parseFloat(document.getElementById("singlePrice"+subStr).value, 10);//单价
			var discountRate = parseFloat(document.getElementById("discountRate"+subStr).value, 10);//折扣率
			
			var totalPrice = amount*singlePrice;
			var discountSPrice = singlePrice*(1-discountRate/100);
			var discountPrice = totalPrice*discountRate/100;
			
			document.getElementById("totalPrice"+subStr).value = totalPrice;//金额
			document.getElementById("price2"+subStr).innerHTML = totalPrice == 0 ? "0" : amountFormat(totalPrice);//金额显示
			document.getElementById("discountSPrice"+subStr).value = discountSPrice;//折扣后单价
			document.getElementById("price3"+subStr).innerHTML = discountSPrice == 0 ? "0" : amountFormat(discountSPrice);//折扣后单价显示
			document.getElementById("discountPrice"+subStr).value = discountPrice;//折扣额
			document.getElementById("price4"+subStr).innerHTML = discountPrice == 0 ? "0" : amountFormat(discountPrice);//折扣额显示
			
			orderTotal += orderAmount;
			amountTotal += amount;
			priceTotal += totalPrice;
			discountTotal += discountPrice;
		}
		
		document.getElementById("orderTotal").innerHTML = orderTotal;
		document.getElementById("amountTotal").innerHTML = amountTotal;
		document.getElementById("reqTotalAmount").value = amountTotal;
		document.getElementById("priceTotal").innerHTML = priceTotal == 0 ? "0" : amountFormat(priceTotal);
		document.getElementById("discountTotal").innerHTML = discountTotal == 0 ? "0" : amountFormat(discountTotal);
		document.getElementById("orderTotalPrice").value = parseFloat(priceTotal, 10) - parseFloat(discountTotal, 10);
		document.getElementById("show2").innerHTML = amountFormat(parseFloat(priceTotal, 10) - parseFloat(discountTotal, 10));
		document.getElementById("discountTotalPrice").value = discountTotal;
	}
</script>
</body>
</html>
